<template>
	<view class="address">
		<view class="flexJusp" style="line-height:112rpx;border-bottom: 2rpx solid #F0F0F0;padding:0 20rpx;">
			<view>真实姓名</view>
			<input v-model="name" style="margin-top:36rpx;text-align: right;font-size:28rpx;height:40rpx;"
				placeholder-style="color: #999999;" placeholder="请输入真实姓名" />
		</view>
		<view class="flexJusp" style="line-height:112rpx;border-bottom: 2rpx solid #F0F0F0;padding:0 20rpx;">
			<view>身份证号</view>
			<input maxlength="18" v-model="mobile" type="number"
				style="margin-top:34rpx;text-align: right;font-size:28rpx;height:40rpx;"
				placeholder-style="color: #999999;" placeholder="请输入身份证号" />
		</view>
		<view style="padding:0 20rpx 16rpx;">
			<view style="margin:30rpx 0 10rpx;">身份证件</view>
			<view style="text-align: center;width:372rpx;">
				<image @click="upImage" style="width:372rpx;height:236rpx;border-radius:10rpx;"
					:src="images ||this.$loadImage('cardZheng')"></image>
				<view style="font-size: 24rpx;color: #666666;margin-bottom:28rpx;">（上传人像面）</view>
				<image @click="upImages" style="width:372rpx;height:236rpx;border-radius:10rpx;"
					:src="imagex ||this.$loadImage('cardFan')"></image>
				<view style="font-size: 24rpx;color: #666666;">（上传国徽面）</view>
			</view>
		</view>
		<view class="buttons" @click="addAddress">提交认证</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				idcard: '',
				images: '',
				imagex: ''
			};
		},
		onLoad(option) {},
		methods: {
			backs() {
				uni.navigateBack()
			},
			upImage() {
				var that = this
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], //从相册选择
					success: function(res) {
						that.images = res.tempFilePaths[0]
						// that.$upShop('common/upload',res.tempFilePaths[0]).then(rex => {
						// 	let arr = JSON.parse(rex.data)
						// 	that.user.avatar = arr.data.url
						// }).catch((e) => {
						// });
					}
				})
			},
			upImages() {
				var that = this
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], //从相册选择
					success: function(res) {
						that.imagex = res.tempFilePaths[0]
						// that.$upShop('common/upload',res.tempFilePaths[0]).then(rex => {
						// 	let arr = JSON.parse(rex.data)
						// 	that.user.avatar = arr.data.url
						// }).catch((e) => {
						// });
					}
				})
			},
			changes(e) {
				console.log(e, '--------')
			},
			getAddressInfo() {
				this.$httpapi('/api/getAddressInfo', 'POST', {
					id: this.id
				}).then(res => {
					this.defaults = res.data.defaultFlag
					this.area = res.data.area
					this.city = res.data.city
					this.address = res.data.address
					this.name = res.data.name
					this.mobile = res.data.phone
					this.province = res.data.province
					this.citys[this.province, this.city, this.area]
				})
			},
			bindPickerChange(e) {
				console.log(e, '---------')
				this.province = e.detail.value[0]
				this.city = e.detail.value[1]
				this.area = e.detail.value[2]
			},
			addressXuan() {
				var that = this
				uni.chooseLocation({
					success: (data) => {
						that.address = data.name;
					}
				})
			},
			addAddress() {
				this.$httpapi('shiming', 'POST', {
					name: this.name,
					idcard: this.idcard,
					shengzheng: this.images,
					shengfan: this.imagex
				}).then(res => {
					uni.showToast({
						title: res.msg,
						duration: 1500,
						icon: 'none'
					});
					if (res.code == 200) {
						setTimeout(() => {
							uni.navigateBack()
						}, 1500)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.address {
		padding: 0 0 30rpx;

		.buttons {
			margin: 120rpx auto 0;
			text-align: center;
			width: 710rpx;
			height: 88rpx;
			background: linear-gradient(180deg, #2089FF 0%, #11ACEF 100%);
			border-radius: 44rpx;
			color: #FFFFFF;
			line-height: 88rpx;
		}
	}
</style>
